package com.hust.bridgecheck.serviceImpl.UserManagement;

import com.hust.bridgecheck.entity.UserGroup;
import com.hust.bridgecheck.repository.GroupRepository;
import com.hust.bridgecheck.service.UserManagement.GroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GroupServiceImpl implements GroupService {
    @Autowired
    private GroupRepository groupRepository;

    @Override
    public UserGroup addGroup(UserGroup userGroup) {

        return groupRepository.save(userGroup);
    }


    @Override
    public void deleteGroup(Integer GroupID){

        groupRepository.deleteById(GroupID);
    }

    @Override
    public List<UserGroup> getAllGroup(){
        return groupRepository.findAll();
    }

    @Override
    public UserGroup updateGroup(UserGroup userGroup){

        return groupRepository.save(userGroup);
    }

    @Override
    public UserGroup getGroupByID(Integer GroupID){

        return groupRepository.findById(GroupID).get();
    }
}
